package com.winner.es.dao;

import com.winner.es.model.Employee;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;

/**
 * 除了Employee实体类, 还要有 EmployeeRepository接口, 启动后才可以自动创建索引库和mapping映射
 *
 * 接口关系：
 * ElasticsearchRepository --> ElasticsearchCrudRepository --> PagingAndSortingRepository --> CrudRepository
 * 继承ElasticsearchRepository里面封装很多操作ES的方法
 *
 */
public interface EmployeeRepository extends ElasticsearchRepository<Employee, String> {

      // 注意这里的 name  和 employeeId在实体类要有, 否则会报错
    Page<Employee> findByNameAndEmployeeId(String name, Integer employeeId, Pageable pageable);

}
